#pragma once

#include "DirectX Headers.h"
#include "Headers.h"

struct	TexturePack		// small struct containing a pointer to the texture and its image info
{
	LPDIRECT3DTEXTURE9	lpTexture;
	D3DXIMAGE_INFO		imgInfo;

	inline bool operator==(TexturePack comparee)
	{
		if(this->lpTexture == comparee.lpTexture)
		{
			return true;
		}
		return false;
	}
};

struct XY
{
	int x;
	int y;
	XY():x(0),y(0){}
	XY(int x,int y):x(x),y(y){}
	void operator=(XY rhs)
	{
		this->x = rhs.x;
		this->y = rhs.y;
	}
	void operator=(COORD rhs)
	{
		this->x = rhs.X;
		this->y = rhs.Y;
	}
};

class Cursor
{
private:
	Cursor(){}
	POINT		m_Point;
	RECT		m_BaseRect;
	RECT		m_rClientRect;
	float		m_fxMod;
	float		m_fyMod;
	COORD		m_Pos;
	HWND		m_hWnd;
public:
	~Cursor()
	{
		m_hWnd = NULL;
	}
	inline static Cursor* Access()
	{static Cursor myCursor;return &myCursor;}
	inline bool Init(HWND hWnd,RECT ClientRect)
	{
		m_hWnd = hWnd;
		m_BaseRect = ClientRect;
		GetClientRect(m_hWnd,&m_rClientRect);
		m_fxMod = (float)m_rClientRect.right / (float)m_BaseRect.right;
		m_fyMod = (float)m_rClientRect.bottom / (float)m_BaseRect.bottom;
		return true;
	}
	inline COORD Find()
	{
		GetClientRect(m_hWnd,&m_rClientRect);
		m_fxMod = (float)m_rClientRect.right / (float)m_BaseRect.right;
		m_fyMod = (float)m_rClientRect.bottom / (float)m_BaseRect.bottom;
		GetCursorPos(&m_Point);
		ScreenToClient(m_hWnd,&m_Point);
		m_Pos.X = (SHORT)(m_Point.x / m_fxMod);
		m_Pos.Y = (SHORT)(m_Point.y / m_fyMod);
		return m_Pos;
	}
};